package com.xjoyt.pay.gateway.forein;

import java.util.List;
import java.util.Map;

import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.xjoyt.pay.constants.ApiConstant;
import com.xjoyt.pay.dto.ExecuteResult;
import com.xjoyt.pay.dto.PageParam;
import com.xjoyt.pay.dto.PageResult;
import com.xjoyt.pay.gateway.params.AlipayOrderParam;
import com.xjoyt.pay.gateway.params.AlipayWapPayParam;
import com.xjoyt.pay.gateway.params.BankPayParam;
import com.xjoyt.pay.gateway.params.CallbackParam;
import com.xjoyt.pay.gateway.params.OrderParam;
import com.xjoyt.pay.gateway.params.ScannedCodeParam;
import com.xjoyt.pay.gateway.params.WechatWapPayParam;
import com.xjoyt.pay.master.dto.CallbackResult;
import com.xjoyt.pay.master.dto.OrderUrlResult;
import com.xjoyt.pay.master.params.MerchantOrderGroupParam;
import com.xjoyt.pay.master.params.OrderPageParam;
import com.xjoyt.pay.master.po.Order;
import com.xjoyt.pay.master.vo.MerchantOrderGroup;
import com.xjoyt.pay.master.vo.OrderMap;
import com.xjoyt.pay.vo.PayType;


@FeignClient(name = ApiConstant.SERVER_ID_MASTER, path = "order")
public interface IMainOrderService {

	/**
	 * 微信扫码统一下单
	 * 
	 * @param param
	 * @return
	 */
	@RequestMapping(value = "wechatScan", method = RequestMethod.POST)
	ExecuteResult<OrderUrlResult> wechatScan(OrderParam param);
	
	/**
	 * 通过ID获取订单
	 * 
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "get/{id}")
	Order get(@PathVariable("id") String id);

	/**
	 * 通过系统单号呼求偶订单
	 * 
	 * @param no
	 * @return
	 */
	@RequestMapping(value = "getByNo/{no}")
	Order getByNo(@PathVariable("no") String no);

	/**
	 * 通过第三方单号获取订单
	 * 
	 * @param customerNo
	 * @return
	 */
	@RequestMapping(value = "getByCustomerNo/{customerNo}")
	Order getByCustomerNo(@PathVariable("customerNo") String customerNo);

	/**
	 * 查询分页
	 * 
	 * @param params
	 * @return
	 */
	@RequestMapping(value = "loadPage", method = RequestMethod.POST)
	PageResult<Order> loadPage(PageParam<OrderPageParam> params);

	/**
	 * 查询分页
	 * 
	 * @param params
	 * @return
	 */
	@RequestMapping(value = "loadPageMap", method = RequestMethod.POST)
	PageResult<OrderMap> loadPageMap(PageParam<OrderPageParam> params);

	/**
	 * 统一回调
	 * 
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "callback", method = RequestMethod.POST)
	ExecuteResult<CallbackResult> callback(CallbackParam param) throws Exception;

	/**
	 * 支付宝扫码统一下单
	 * 
	 * @param param
	 * @return
	 */
	@RequestMapping(value = "alipayScan", method = RequestMethod.POST)
	ExecuteResult<OrderUrlResult> alipayScan(AlipayOrderParam param);

	/**
	 * 网关支付统一下单
	 * 
	 * @param param
	 * @return
	 */
	@RequestMapping(value = "bankPay", method = RequestMethod.POST)
	ExecuteResult<OrderUrlResult> bankPay(BankPayParam param);

	/**
	 * 支付宝wap支付统一下单
	 * 
	 * @param param
	 * @return
	 */
	@RequestMapping(value = "alipayWapPay", method = RequestMethod.POST)
	ExecuteResult<OrderUrlResult> alipayWapPay(AlipayWapPayParam param);

	/**
	 * 微信wap支付统一下单
	 * 
	 * @param param
	 * @return
	 */
	@RequestMapping(value = "wechatWapPay", method = RequestMethod.POST)
	ExecuteResult<OrderUrlResult> wechatWapPay(WechatWapPayParam param);

	/**
	 * 被扫码支付统一下单
	 * 
	 * @param param
	 * @return
	 */
	@RequestMapping(value = "scannedCodePay", method = RequestMethod.POST)
	ExecuteResult<OrderUrlResult> scannedCodePay(ScannedCodeParam param);

	/**
	 * 获取支付类型
	 * 
	 * @return
	 */
	@RequestMapping("getAllPayType")
	Map<PayType, String> getAllPayType();

	/**
	 * 结算
	 * 
	 * @param param
	 * @return
	 */
	@RequestMapping(value = "checkout", method = RequestMethod.POST)
	ExecuteResult<Order> checkout(OrderParam param);

	/**
	 * 订单汇总
	 * 
	 * @param param
	 * @return
	 */
	@RequestMapping(value = "loadPageGroup", method = RequestMethod.POST)
	PageResult<MerchantOrderGroup> loadPageGroup(PageParam<MerchantOrderGroupParam> param);

	/**
	 * 查询所有订单
	 */
	@RequestMapping(value = "findAll", method = RequestMethod.POST)
	List<Order> findAll(OrderPageParam params);
}
